<?php

abstract class Application_Model_UnionUser_Base{
    
    /**
     * 创建联合登录器
     * @param type $name
     * @return Application_Model_UnionUser_Base
     */
    public static function createUnion($name){
        $className = 'Application_Model_UnionUser_'.$name;
        return new $className;
    }   
    
    /**
     * 是否是可以通过验证的
     */
    public abstract function isValid();

    /**
     * 返回联合登录的网址
     */
    public abstract function getLoginUrl();
    
    /**
     * 返回用户Key
     */
    public abstract function getUserKey();

    /**
     * 返回用户信息
     * @return Application_Model_UnionUser_UserInfo
     */
    public abstract function getUserInfo();
    
    /**
     * 返回登录器的名字
     */
    public abstract function getUnionName();
    

    protected function get_url_contents($url)
    {
        if (ini_get("allow_url_fopen") == "1")
            return file_get_contents($url);

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
        curl_setopt($ch, CURLOPT_URL, $url);
        $result =  curl_exec($ch);
        curl_close($ch);

        return $result;
    }

}